package com.buptse.utils;

import com.buptse.model.Information;

public class SourceDecoder {
    enum SourceCategory {
        //编码枚举类
        _100("100",new String[]{"业务报送数据","前方地震应急指挥部"}),
        _101("101",new String[]{"业务报送数据","后方地震应急指挥部"}),
        _120("120",new String[]{"业务报送数据","应急指挥技术系统"}),
        _121("121",new String[]{"业务报送数据","社会服务工程应急救援系统"}),
        _140("140",new String[]{"业务报送数据","危险区预评估工作组"}),
        _141("141",new String[]{"业务报送数据","地震应急指挥技术协调组"}),
        _142("142",new String[]{"业务报送数据","震后政府信息支持工作项目组"}),
        _180("180",new String[]{"业务报送数据","灾情快速上报接受处理系统"}),
        _181("181",new String[]{"业务报送数据","地方地震局应急信息服务相关技术系统"}),
        _199("199",new String[]{"业务报送数据","其他"}),
        _200("200",new String[]{"泛在感知数据","互联网感知"}),
        _201("201",new String[]{"泛在感知数据","通信网感知"}),
        _202("202",new String[]{"泛在感知数据","舆情网感知"}),
        _203("203",new String[]{"泛在感知数据","电力系统感知"}),
        _204("204",new String[]{"泛在感知数据","交通系统感知"}),
        _205("205",new String[]{"泛在感知数据","其他"}),
        _300("300",new String[]{"其他",""});

        private String code;
        private String[] description;

        // 枚举的构造函数，可以带不同的参数
        SourceCategory(String code, String[] description) {
            this.code = code;
            this.description=description;
        }
        public String getCode() {
            return code;
        }
        public String[] getDescription() {
            return description;
        }
        public static String[] getInfoByCode(String code) {
            for (SourceCategory sourceCategory : values()) {
                if (sourceCategory.getCode().equals(code)) {
                    return sourceCategory.getDescription();
                }
            }
            return new String[]{"Code not found"};
        }

    }

   public static void sourceDecode(String code, Information information){
        String[] sourceInformation=SourceCategory.getInfoByCode(code);
        information.setSource(sourceInformation[1]);
   }

}
